package ChatSystem;

import chatController.ChatController;

import chatGUI.*;
import chatModel.*;

import chatNI.*;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author deepali and vansh
 */
public class ChatSystem {

    private ChatGui gui;
    private ChatController controller;
    private ChatModel model;
    private ChatNI ni;

    /**
     * This has the main method and creates an instance of chat model, chat
     * controller and chat GUI
     */
    private ChatSystem() throws SocketException {

        this.model = new ChatModel();

        this.gui = new ChatGui(model);
        this.ni = new ChatNI(model);
        try {
            ni.getIpOfInterfac("eth0");
        } catch (UnknownHostException ex) {
            Logger.getLogger(ChatSystem.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.controller = new ChatController(model, gui, ni);
        this.gui.setCc(controller);
        this.ni.setController(controller);
        model.addObserver(ni);
        model.addObserver(gui);
    }

    public static void main(String[] args) throws SocketException {
        ChatSystem cs = new ChatSystem();
    }
}
